package com.it.web.controller;

import com.it.common.aspect.ApiOperationLog;
import com.it.common.utils.Response;
import com.it.web.model.dto.category.FindCategoryArticlePageListDto;
import com.it.web.model.dto.category.FindCategoryLisDto;
import com.it.web.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/category")
@Api(tags = "分类")
public class CategoryController {

    @Resource
    private CategoryService categoryService;


    @PostMapping("/list")
    @ApiOperation(value = "前台获取分类列表")
    @ApiOperationLog(description = "前台获取分类列表")
    public Response findCategoryList(@RequestBody @Validated FindCategoryLisDto findCategoryLisDto) {
        return categoryService.findCategoryList(findCategoryLisDto);

    }


    /**
     * @param findCategoryArticlePageListDto
     * @return {@link Response }
     */
    @PostMapping("/article/list")
    @ApiOperation(value = "前台获取分类下文章分页数据")
    @ApiOperationLog(description = "前台获取分类下文章分页数据")
    public Response findCategoryArticlePageList(@RequestBody @Validated FindCategoryArticlePageListDto findCategoryArticlePageListDto){
        return categoryService.findCategoryArticlePageList(findCategoryArticlePageListDto);
    }


}
